/**
 * Created with IntelliJ IDEA.
 * Description:测试
 * User: 李家强
 * Date: 2022-08-01
 * Time: 14:38
 */

public class TestTree {
    public static void main(String[] args) {
        BinaryTree binaryTree = new BinaryTree();
        binaryTree.createTree();

        System.out.println("========前序遍历=========");
        binaryTree.preOrder(binaryTree.root);
        System.out.println();

        System.out.println("========中序遍历=========");
        binaryTree.inOrder(binaryTree.root);
        System.out.println();

        System.out.println("========后序遍历=========");
        binaryTree.postOrder(binaryTree.root);
        System.out.println();

        System.out.println("========遍历思路:获取树中的节点个数=========");
        System.out.println("节点的个数:"+binaryTree.size2(binaryTree.root));

        System.out.println("========子问题思路:获取树中的节点个数=========");
        System.out.println("节点的个数:"+binaryTree.size1(binaryTree.root));

        System.out.println("========子问题思路:获取叶子节点的个数:=========");
        System.out.println("叶子节点的个数"+binaryTree.getLeafNodeCount1(binaryTree.root));

        System.out.println("========遍历思路:获取叶子节点的个数:=========");
        System.out.println("叶子节点的个数"+binaryTree.getLeafNodeCount2(binaryTree.root));

        System.out.println("========获取第k层节点的个数:=========");
        System.out.println("第k层节点的个数:"+ binaryTree.getKLevelNodeCount(binaryTree.root,4));

        System.out.println("========获取二叉树的高度:=========");
        System.out.println("二叉树的高度:"+ binaryTree.getHeight(binaryTree.root));

        System.out.println("========检测值为value的元素是否存在:=========");
        System.out.println(binaryTree.find(binaryTree.root, 'o')); //结果不为null即存在

        System.out.println("========层序遍历=========");
        binaryTree.levelOrder(binaryTree.root);
        System.out.println();

        System.out.println("========分层遍历=========");
        System.out.println(binaryTree.levelOrder2(binaryTree.root));

        System.out.println("========判断是不是完全二叉树=========");
        System.out.println(binaryTree.isCompleteTree(binaryTree.root));

    }
}
